Skip to content

Audio/Video desync when framerate is not an integer #486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Max6mm opened this issue Feb 9, 2025 · 2 comments
Open

Audio/Video desync when framerate is not an integer #486

Max6mm opened this issue Feb 9, 2025 · 2 comments

Comments

@Max6mm
Copy link

Max6mm commented Feb 9, 2025

When using a driving video with non integer framerate , 29.97 FPS in my case, LivePortrait round it to 29 FPS.
It create an audio/video desync which become more important the longer the video is.

@cleardusk
Copy link
Member

A temporary solution is use change_video_fps to change the FPS of the original video to an interger, e.g., 30

def change_video_fps(input_file, output_file, fps=20, codec='libx264', crf=12):
cmd = f'ffmpeg -i "{input_file}" -c:v {codec} -crf {crf} -r {fps} "{output_file}" -y'
exec_cmd(cmd)

@tacitus-git
Copy link

Also, you could edit the live_portrait_pipline.py file on lines 96 and 132 which cast the source and driving items FPS's to an integer. why? Good Question!

Change line 96 from: source_fps = int(get_fps(args.source)) to: source_fps = get_fps(args.source)
Change line 132 from: output_fps = int(get_fps(args.driving)) to: output_fps = get_fps(args.driving)

I can only speculate on why the FPS was cast to an integer. But, after changing the code, LivePortrait works perfectly now with videos of any FPS rate.

I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants